{extend name='../base/index/main'}

{block name='main'}
<style>
    .hide{display: none;}
</style>
<div class="layui-layout">

    <form class="layui-form layui-form-pane" action="{:url('Trading/add_action')}" method="post">
        <fieldset class="layui-elem-field">
            <legend>添加收支管理</legend>

            <div class="layui-field-box">

                {:CMaker('relation')->label('业务种类')->helpinfo('')->table('business_categroy')->field('id,bname')->choose($business_id)->showtype('select')->name('business_id')->layFilter('business_categroy')->layVerify('required')->render()}
                {:CMaker('relation')->label('收支类型')->helpinfo('')->table('trading_type')->field('id,type_name')->showtype('select')->name('type_id')->layVerify('required')->render()}
                {:CMaker('number')->label('金额')->helpinfo('')->placeholder('')->name('money')->layVerify('required|number')->render()}
                {:CMaker('number')->label('手续费')->helpinfo('')->placeholder('')->name('service_money')->layVerify('required|number')->render()}
                <div class="hide" >
                {:CMaker('relation')->label('账号类型')->helpinfo('')->table('account_type')->field('id,account_name')->showtype('select')->name('account_type_id')->layVerify('')->render()}
                {:CMaker('text')->label('账号名称')->helpinfo('')->placeholder('')->name('account_name')->layVerify('')->render()}
                </div>
                {:CMaker('relation')->label('交易渠道')->helpinfo('')->table('trading_channel')->field('id,trading_name')->showtype('select')->name('channel_id')->layVerify('required')->render()}
                {:CMaker('textarea')->label('备注')->helpinfo('')->name('remark')->layVerify('')->render()}


            </div>


        </fieldset>


        <div class="layui-form-item">
            <div class="layui-input-inline ">
                <button class="layui-btn"  lay-submit data-call-back="clearform" >提交</button>
                <button type="reset" class="layui-btn layui-btn-primary reset">重置</button>
            </div>
        </div>

    </form>
</div>


<script type="text/javascript" src="__PLUGIN_PATH__/layui/layui.js"></script>
<script type="text/javascript" src="__PLUGIN_PATH__/lay-extend-module/config.js"></script>


{:CMakerJs("all")}

<script>
    layui.use(['form'],function () {
        var form = layui.form;
        var $ = layui.jquery;
        $bid = "{$business_id}";
        if(parseInt($bid) == 2)$('.hide').css('display','block');
        form.on('select(business_categroy)',function(o){
            if(o.value == 2){
                $('.hide').css('display','block');
            }else{
                $('.hide').css('display','none');
            }
        })
    });

    function clearform(){
        $('.reset').trigger('click');
    }
</script>

{/block}

